<? 
	if(isset($_POST['btngo']))
	{
		require("required/dbconnect.php");
		$pageno=$_POST['pageno'];
		
		header("Location:os_announcement_view_all.php?page=$pageno");
	}
	
	$title="Shop";
	require("required/dbconnect.php");
	require("required/share_function.php");
	$_SESSION['pid']="promotion_news";
	require("required/header.php"); 
	
	
	if(empty($_GET['page']))
	{
		$page="1";
	}
	else
	{
		$page=$_GET['page'];
	}
	
	$totalperpage=6;

	$from=($page-1)*$totalperpage;	
	$get=mysql_query("select * from os_announcement where status=1 order by create_date desc limit $from,$totalperpage")or die(mysql_error());
	$get_all=mysql_query("select count(*) as result from os_announcement where status=1 order by create_date desc")or die(mysql_error());
	
	
	$count=mysql_result($get_all,0,"result");

	$tr1="";
	$tr2="";


?>
			
				<table width="100%" cellpadding="5" cellspacing="0"  >
					
					<tr>
						
						<Td valign="top">
                        	<table width="100%">
                                <Td class="page_location">Your Location : <a href="index.php">Home</a>  > 
                                Promotions &amp; News</Td>
                            </table>
							<table width="100%">
							<?	
								if($count==0)
								{
							?>
								<tr>
									<td align="center"> :: No Record Found :: </td>
								</tr>
							<?	
								}
								else
								{
							?>
							
                            <tr>
								<td width="100%" colspan="6" align="left">
                                	
									<?= getPaging($totalperpage,$count,$page,"os_announcement_view_all.php?param=ntg") ?>
								</td>
								
							</tr>
							<?
								while($a=mysql_fetch_array($get,MYSQL_ASSOC))
								{
							?>
                            <tr>
                                <td>
                                    <table width="100%"> 
                                          <tr>
                                              <td align="center" width="20%">
                                                <?
                                                    if($a["pic"]=="")
                                                    {
                                                        $pic="empty";
                                                        $piclink="noimage.jpg";
                                                        $fix="";
                                                    }
                                                    else
                                                    {
                                                        $piclink=$a['pic'];
                                                        $width=$a['width'];
                                                        $height=$a['height'];
                                                        
                                                        if($width-$height>0)
                                                        {
                                                            $fix="width=100";
                                                        }
                                                        else
                                                        {
                                                            $fix="height=100";
                                                        }						
                                                        
                                                    }					
                                                ?>
                                               <img src="announcement_pic/<?= $piclink ?>" <?= $fix ?>  style="border:3px solid #66669a" />
                                              
                                              </td>
                                              <td valign="top" width="80%">
                                              <font color="#66669a"><strong><?= $a['title'] ?></strong></font><br />
                                                (<?= $a['create_date'] ?>)
                                                <br /><br />
                                              
                                              <?= $a['brief_description'] ?>
                                              <br />
                                              <div align="right">
                                              <input type="button" value="Read More" onclick="window.open('os_announcement_view_full.php?id=<?= $a['id'] ?>','_self')" class="button">
 											</div>
                                              
                                              
                                              </td>
                                          </tr>                          
                                    </table>
                                </td>
                            </tr>
                            <? } ?>
								
							<tr>
								<td width="100%" colspan="6" align="left">
									<?= getPaging($totalperpage,$count,$page,"os_announcement_view_all.php?param=ntg") ?>
								</td>
								
							</tr>
                            <? } ?>
							</table>
						</Td>
					</tr>		  
			  	</table>
			
<? require("required/footer.php"); ?>	